package com.linkgie.galaxyframework.fileservice;

import java.util.Properties;

import com.linkgie.galaxyframework.metadata.DataEntity;
import com.linkgie.galaxyframework.metadata.DataField;
import com.linkgie.galaxyframework.metadata.DataInterface;
import com.linkgie.galaxyframework.metadata.DataType;
import com.linkgie.galaxyframework.metadata.StandardType;

@DataInterface
@DataEntity
public class FileEntry {

	@DataField(name = "标识符", order = 0)
	private String id;

	@DataField(name = "名称", order = 1)
	private String name;
	
	@DataField(name = "文件名", order = 2)
	private String fileName;

	@DataField(name = "扩展名", order = 3)
	private String type;

	@DataField(name = "大小", order = 4)
	private int size;

	@DataField(name = "校验码(SHA256)", order = 5)
	private String sha256;

	@DataField(name = "内容哈希", order = 6)
	private String contentHash;

	@DataField(name = "分类", order = 10)
	private String subject;
	
	@DataType(dataType = StandardType.TIMESTAMP, contentType = "datetime;format='YYYY-MM-DD hh:mm:ss'")
	@DataField(name = "上传时间", order = 11)
	private long createdTime;
	

	@DataType(dataType = StandardType.BOOL, contentType = "enum;strict=true;false='未发布';true='已发布'")
	@DataField(name = "发布状态", order = 12)
	private boolean published;

	@DataType(dataType = StandardType.TIMESTAMP, contentType = "datetime;format='YYYY-MM-DD hh:mm:ss'")
	@DataField(name = "发布时间", order = 13)
	private Long publishedTime;
	

	@DataType(dataType = StandardType.BOOL, contentType = "enum;strict=true;false='持久';true='临时'")
	@DataField(name = "存储状态", order = 14)
	private boolean temporary;

	@DataField(name = "说明", order = 20)
	private String description;
	
	private Properties attributes;

	public FileEntry() {
	}

	public FileEntry(FileObject fobj) {
		this.setId(fobj.getId());
		this.setName(fobj.getName());
		this.setFileName(fobj.getFileName());
		this.setType(fobj.getType());
		this.setSize(fobj.getSize());
		this.setTemporary(fobj.isTemporary());
		this.setSha256(fobj.getChecksum());
		this.setContentHash(fobj.getContentHash());
		this.setSubject(fobj.getSubject());
		this.setCreatedTime(fobj.getCreatedTime());
		this.setDescription(fobj.getDescription());
		this.setPublished(fobj.getStatus() == FileStatus.PUBLISHED);
		this.setPublishedTime(fobj.getPublishedTime());
		this.setAttributes(fobj.getAttributes());
		
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public int getSize() {
		return size;
	}

	public String getContentHash() {
		return contentHash;
	}

	public boolean isTemporary() {
		return temporary;
	}

	public void setType(String type) {
		this.type = type;
	}

	public void setSize(int size) {
		this.size = size;
	}

	public void setContentHash(String contentHash) {
		this.contentHash = contentHash;
	}

	public void setTemporary(boolean temporary) {
		this.temporary = temporary;
	}

	public long getCreatedTime() {
		return createdTime;
	}

	public void setCreatedTime(long createdTime) {
		this.createdTime = createdTime;
	}

	public String getSha256() {
		return sha256;
	}

	public void setSha256(String sha256) {
		this.sha256 = sha256;
	}

	public Long getPublishedTime() {
		return publishedTime;
	}

	public void setPublishedTime(Long publishedTime) {
		this.publishedTime = publishedTime;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Properties getAttributes() {
		return attributes;
	}

	public void setAttributes(Properties attributes) {
		this.attributes = attributes;
	}

	public boolean isPublished() {
		return published;
	}

	public void setPublished(boolean published) {
		this.published = published;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

}
